<template>
  <div class="box">
    <van-nav-bar title="文章详情" left-arrow @click-left="$router.go(-1)" />
    <div class="content">
      <h4>{{ articledetail.title }}</h4>
      <div class="c-header">
        <img :src="articledetail.pic" alt="" />
        <div>
          <p class="title">{{ articledetail.author }}</p>
          <p class="time">
            {{ new Date(articledetail.create_date) }}
          </p>
        </div>
      </div>
      <!-- 正文 -->
      <p v-html="articledetail.content"></p>
      <!-- 分界线 -->
      <p class="end"><span>正文结束</span></p>
    </div>
    <van-tabbar v-model="active">
      <van-tabbar-item icon="star-o"></van-tabbar-item>
      <van-tabbar-item icon="good-job-o"></van-tabbar-item>
      <van-tabbar-item icon="share"></van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  data () {
    return {
      active: 1
    }
  },
  methods: {
    render () {
      console.log(1)
      this.$store.dispatch('article/getdetails', this.$route.params.id)
    }
  },
  created () {
    this.render()
  },
  computed: {
    ...mapState('article', ['articledetail'])
  }
}
</script>

<style scoped lang="less">
// 内容区域
.content {
  padding: 12px;
  // 用户名
  h4 {
    font-size: 24px;
  }
  // 用户信息
  .c-header {
    display: flex;
    align-items: center;
    // 头像
    img {
      width: 50px;
      height: 50px;
      border-radius: 50%;
    }
    p {
      margin-left: 10px;
      line-height: 10px;
    }
    .time {
      color: #ccc;
    }
  }
  // 正文结束分割线
  .end {
    color: #ccc;
    border-bottom: 1px solid #ccc;
    line-height: 0;
    text-align: center;
    span {
      padding: 0 10px;
      background-color: #fff;
    }
  }
}
.van-nav-bar {
  position: fixed;
  width: 100vw;
  background-color: #003366;
  ::v-deep .van-nav-bar__title {
    font-size: 24px;
    color: #fff;
  }
}

.box {
  width: 100%;
}
</style>
